<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<script>
	$(function() {
		$('#staffMgt_stuffMgt_datagrid').datagrid({
			url : 'stuffAction!getDatagrid.action',
			fitColumns : false,
			border : false,
			pagination : true,
			pageSize : 20,
			fit : true,
			singleSelect : true,
			rownumbers : true,
			idField : 'pkStuff',
			//sortName : 'name',
			columns : [ [ {
				field : 'pkStuff',
				title : '员工编号',
				width : 150,
				//hidden : true,
				align : 'center'
			}, {
				field : 'name',
				title : '员工姓名',
				width : 150,
				sortable : true,
				align : 'center',
			}, {
				field : 'pkVenueInfo',
				title : '所属场编号',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'venueName',
				title : '所属场馆名',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'birthday',
				title : '生日',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'gender',
				title : '性别',
				width : 75,
				sortable : true,
				align : 'center'
			}, {
				field : 'idNumber',
				title : '身份证号',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'phone',
				title : '电话号码',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'workStatus',
				title : '在职状态',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'cdatetime',
				title : '创建时间',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'mdatetime',
				title : '最后修改时间',
				width : 150,
				sortable : true,
				align : 'center'
			} ] ],

			toolbar : [ {
				iconCls : 'icon-search',
				text : '查询',
				handler : function() {
					$('#staffMgt_stuffMgt_searchDialog').dialog('open');
				}
			}, '-', {
				iconCls : 'icon-add',
				text : '增加',
				handler : function() {
					$('#staffMgt_stuffMgt_addForm').form('clear');
					$('#staffMgt_stuffMgt_addDialog').dialog('open');
				}
			}, '-', {
				iconCls : 'icon-edit',
				text : '修改',
				handler : function() {
					stuffEdit();

				}
			}, '-', {
				iconCls : 'icon-remove',
				text : '删除',
				handler : function() {
					stuffRemove();
				}
			} ],
		});

		$('#staffMgt_stuffMgt_addForm').form({
			url : 'stuffAction!add.action',
			success : function(r) {
				var obj = jQuery.parseJSON(r);
				if (obj.success) {
					$('#staffMgt_stuffMgt_addDialog').dialog('close');
					$('#staffMgt_stuffMgt_datagrid').datagrid('load');
				}
				$.messager.alert({
					title : '提示',
					msg : obj.msg
				});
			}
		});

		$('#staffMgt_stuffMgt_editForm').form({
			url : 'stuffAction!edit.action',
			success : function(r) {
				var obj = jQuery.parseJSON(r);
				if (obj.success) {
					$('#staffMgt_stuffMgt_editDialog').dialog('close');
					$('#staffMgt_stuffMgt_datagrid').datagrid('load');
				}
				$.messager.alert({
					title : '提示',
					msg : obj.msg
				});
			}
		});
	});

	function stuffEdit() {
		var row = $('#staffMgt_stuffMgt_datagrid').datagrid('getSelected');
		if (row != null) {
			$('#staffMgt_stuffMgt_editDialog').dialog('open');
		} else {
			$.messager.alert({
				title : '提示',
				msg : '您未选中任何行！'
			});
		}
	};
	function stuffOpenEditDialog() {
		var row = $('#staffMgt_stuffMgt_datagrid').datagrid('getSelected');
		console.info(row);
		$('#staffMgt_stuffMgt_editForm').form('load', row);
	};

	function stuffRemove() {
		var row = $('#staffMgt_stuffMgt_datagrid').datagrid('getSelected');
		console.info(row);
		var id = null;
		if (row.pkStuff != null) {
			id = row.pkStuff;
			$.ajax({
				url : 'stuffAction!remove.action',
				data : {
					pkStuff : id
				},
				dataType : 'json',
				success : function(info) {
					$('#staffMgt_stuffMgt_datagrid').datagrid('reload');
					$('#staffMgt_stuffMgt_datagrid').datagrid('clearSelections');
					$.messager.alert({
						title : '提示',
						msg : info.msg
					});
				}
			});
		} else {
			$.messager.alert({
				title : '提示',
				msg : '您未选中任何行！'
			});
		}
	};
	function stuffSearchFun() {
		$('#staffMgt_stuffMgt_datagrid').datagrid('load', serializeObject($('#staffMgt_stuffMgt_searchForm')));
	};
	function stuffClearFun() {
		$('#staffMgt_stuffMgt_searchForm').form('clear');
		$('#staffMgt_stuffMgt_datagrid').datagrid('load', {});
	};
</script>

<div class="easyui-panel" data-options="border:false,fit:true">
	<div id="staffMgt_stuffMgt_datagrid_panel" class="easyui-panel" data-options="border:false,fit:true,">
		<table id="staffMgt_stuffMgt_datagrid"></table>
	</div>
</div>

<div id="staffMgt_stuffMgt_addDialog" class="easyui-dialog" style="width: 650px; height: 400px" data-options="iconCls:'icon-add',
		closed:true,
		minimizable:false,
		maximizable:false,
		draggable:false,
		title:' 增加',
		modal:true,
		buttons: [{text:'取消',
					iconCls:'icon-cancel',
					handler:function(){
						$('#staffMgt_stuffMgt_addDialog').dialog('close');
					}
				},{text:'增加',
					iconCls:'icon-add',
					handler:function(){
						$('#staffMgt_stuffMgt_addForm').submit();
					}
				}]
				">
	<form id="staffMgt_stuffMgt_addForm" style="margin: 3%">
		<table style="border-collapse: separate; border-spacing: 15px; width: 580px;">
			<label>基本信息</label>
			<hr s style="height: 1px; border: none; border-top: 1px solid #D8E6E7;" />
			<tr>
				<td>所属场馆名</td>
				<td><input class="easyui-combobox" type="text" name="pkVenueInfo" data-options="required:true,panelHeight:70,
				valueField:'pkVenueInfo',
				textField:'name',
				editable:false,
				url:'venueInfoAction!getComboBox.action'"></input></td>
			</tr>
			<tr>
				<td>员工姓名</td>
				<td><input class="easyui-textbox" type="text" name="name" data-options="required:true,validType:'name'"></input></td>
				<td>员工编号</td>
				<td><input class="easyui-textbox" type="text" name="pkStuff" data-options="readonly:true"></input></td>
			</tr>
			<tr>
				<td>生日</td>
				<td><input class="easyui-datebox" type="text" name="birthday" data-options="required:true"></input></td>
				<td>性别</td>
				<td><select class="easyui-combobox" type="text" name="gender" data-options="required:true,editable:false,panelHeight:70" style="width: 70px;">
						<option value="男">男</option>
						<option value="女">女</option>
				</select></td>
			</tr>
			<tr>
				<td>身份证号</td>
				<td><input class="easyui-textbox" type="text" name="idNumber" data-options="required:true,validType:'idcard'"></input></td>
				<td>电话号码</td>
				<td><input class="easyui-textbox" type="text" name="phone" data-options="required:true,validType:'mobile'"></input></td>
			</tr>
			<tr>
				<td>在职状态</td>
				<td><select class="easyui-combobox" type="text" name="workStatus" data-options="required:true,editable:false,panelHeight:70" style="width: 70px;">
						<option value="在职">在职</option>
						<option value="离职">离职</option>
				</select></td>
			</tr>
			<tr>
				<td>入职日期</td>
				<td><input class="easyui-datebox" type="text" name="inDate" data-options="required:true"></input></td>
				<td>离职日期</td>
				<td><input class="easyui-datebox" type="text" name="outDate" data-options=""></input></td>
			</tr>
		</table>
		<table cellpadding="10" style="margin-top: 15px ;border-collapse: separate; border-spacing: 15px; width: 580px;"">
			<label>操作信息</label>
			<hr s style="height: 1px; border: none; border-top: 1px solid #D8E6E7;" />
			<tr>
				<td>创建时间</td>
				<td><input class="easyui-textbox" type="text" name="cdatetime" data-options="readonly:true"></input></td>
				<td>最后修改时间</td>
				<td><input class="easyui-textbox" type="text" name="mdatetime" data-options="readonly:true"></input></td>
			</tr>
		</table>
	</form>
</div>

<div id="staffMgt_stuffMgt_editDialog" class="easyui-dialog" style="width: 600px; height: 400px" data-options="iconCls:'edit-add',
		closed:true,
		minimizable:false,
		maximizable:false,
		draggable:false,
		title:' 修改',
		modal:true,
		buttons: [{text:' 取消',
					iconCls:'icon-cancel',
					handler:function(){
						$('#staffMgt_stuffMgt_editDialog').dialog('close');
					}
				},{text:' 修改 ',
					iconCls:'icon-edit',
					handler:function(){
						$('#staffMgt_stuffMgt_editForm').submit();
					}
				}],
				onOpen:function(){
					stuffOpenEditDialog();
				}
				">
	<form id="staffMgt_stuffMgt_editForm" style="margin: 3%">
		<table style="border-collapse: separate; border-spacing: 15px; width: 580px;">
			<label>基本信息</label>
			<hr s style="height: 1px; border: none; border-top: 1px solid #D8E6E7;" />
			<tr>
				<td>所属场馆名</td>
				<td><input class="easyui-combobox" type="text" name="pkVenueInfo" data-options="required:true,panelHeight:70,
				valueField:'pkVenueInfo',
				textField:'name',
				editable:false,
				url:'venueInfoAction!getComboBox.action'"></input></td>
			</tr>
			<tr>
				<td>员工姓名</td>
				<td><input class="easyui-textbox" type="text" name="name" data-options="required:true,validType:'name'"></input></td>

				<td>员工编号</td>
				<td><input class="easyui-textbox" type="text" name="pkStuff" data-options="readonly:true"></input></td>
			</tr>
			<tr>
				<td>生日</td>
				<td><input class="easyui-datebox" type="text" name="birthday" data-options="required:true"></input></td>
				<td>性别</td>
				<td><select class="easyui-combobox" type="text" name="gender" data-options="required:true,editable:false,panelHeight:70" style="width: 70px;">
						<option value="男">男</option>
						<option value="女">女</option>
				</select></td>
			</tr>
			<tr>
				<td>身份证号</td>
				<td><input class="easyui-textbox" type="text" name="idNumber" data-options="required:true,validType:'idcard'"></input></td>
				<td>电话号码</td>
				<td><input class="easyui-textbox" type="text" name="phone" data-options="required:true,validType:'mobile'"></input></td>
			</tr>
			<tr>
				<td>在职状态</td>
				<td><select class="easyui-combobox" type="text" name="workStatus" data-options="required:true,editable:false,panelHeight:70" style="width: 70px;">
						<option value="在职">在职</option>
						<option value="离职">离职</option>
				</select></td>
			</tr>
			<tr>
				<td>入职日期</td>
				<td><input class="easyui-datebox" type="text" name="inDate" data-options="required:true"></input></td>
				<td>离职日期</td>
				<td><input class="easyui-datebox" type="text" name="outDate" data-options=""></input></td>
			</tr>
		</table>
		<table  style="margin-top: 15px ;border-collapse: separate; border-spacing: 15px; width: 580px;"">
			<label>操作信息</label>
			<hr s style="height: 1px; border: none; border-top: 1px solid #D8E6E7;" />
			<tr>
				<td>创建时间</td>
				<td><input class="easyui-textbox" type="text" name="cdatetime" data-options="readonly:true"></input></td>
				<td>最后修改时间</td>
				<td><input class="easyui-textbox" type="text" name="mdatetime" data-options="readonly:true"></input></td>
			</tr>
		</table>
	</form>
</div>


<div id="staffMgt_stuffMgt_searchDialog" class="easyui-dialog" title="查询" style="width: 600px; height: 300px" data-options="iconCls:'icon-search',modal:true,closed:true,collapsible:false,minimizable:false,maximizable:false,
		buttons: [{text:'重置查询结果',
					iconCls:'icon-reload',
					handler:function(){
						stuffClearFun();
						$('#staffMgt_stuffMgt_searchDialog').dialog('close');
					}
				},
		{text:'重置查询条件',
					iconCls:'icon-redo',
					handler:function(){
						$('#staffMgt_stuffMgt_searchForm').form('clear');
					}
				},{text:'查询',
					iconCls:'icon-search',
					handler:function(){	
						stuffSearchFun();
						$('#staffMgt_stuffMgt_searchDialog').dialog('close');
					}
				}]">

	<form id="staffMgt_stuffMgt_searchForm" style="margin: 5%">
		<table  style="margin-top: 15px;border-collapse: separate; border-spacing: 15px; width: 450px;">
			<tr>
				<td>员工姓名</td>
				<td><input class="easyui-textbox" type="text" name="name" data-options=""></input></td>
				<td>性别</td>
				<td><select class="easyui-combobox" type="text" name="gender" data-options="required:true,editable:false,panelHeight:70" style="width: 70px;">
						<option value="男">男</option>
						<option value="女">女</option>
				</select></td>
			</tr>
			<!--  <tr>
				<td>员工编号</td>
				<td><input class="easyui-textbox" type="text" name="pkStuff" data-options=""></input></td>
			</tr>-->

		</table>
	</form>
</div>